function addAllToCart(){
    quantity = 1;
    
    var $ids = '';
    var $items = document.forms['bought_together_form'].bought_together_item;

    var html = '';
	
	var j
    for (j=0; j<$items.length; j++)
    {
		if($items[j].checked)
        {
            var str = $items[j].value;
            var v = str.indexOf("_");
            $ids = $ids + str.substr(v+1) + ',';                    
        }
    }
	
	if($items[0].checked) {
		$.ajax({
			url: 'index.php?route=checkout/cart/add',
			type: 'post',
			data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
			dataType: 'json',
			success: function(json) {
				$('.success, .warning, .attention, information, .error').remove();
				
				if (json['error']) {
					if (json['error']['option']) {
						for (i in json['error']['option']) {
							$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
						}
					}
					
					html = html + '<div class="success error">Please enter the full information in the option<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>';
					
					$('#notification').html(html);
				} 
				
				if (json['success']) {
				 
					html = html + '<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>';
						
					$('.success').fadeIn('slow');
						
					$('#cart-total').html(json['total']);
					
					$('html, body').animate({ scrollTop: 0 }, 'slow'); 
					
					//--------------
					var n=$ids.split(",");
					for (j=1; j<(n.length)-1; j++){
						$.ajax({
                    		url: 'index.php?route=checkout/cart/add',
                    		type: 'post',
                    		data: 'product_id=' + n[j] + '&quantity=' + quantity,
                    		dataType: 'json',
                    		success: function(json) {
                    			$('.success, .warning, .attention, .information, .error').remove();
                    			
                    			if (json['redirect']) {
                    				location = json['redirect'];
                    			}
                    			
                    			if (json['success']) {
                    				 
                    				html = html + '<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>';
                    			 
                    				$('#notification').html(html);
                    				
                    				$('.success').fadeIn('slow');
                    				
                    				$('#cart-total').html(json['total']);
                    				
                    				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
                    			}	
                    		}
                    	});
					}  
					//------------
				}	
			}
		}); 
		
	} else {
		var n=$ids.split(",");
		for (j = 0; j<(n.length)-1; j++){
			$.ajax({
        		url: 'index.php?route=checkout/cart/add',
        		type: 'post',
        		data: 'product_id=' + n[j] + '&quantity=' + quantity,
        		dataType: 'json',
        		success: function(json) {
        			$('.success, .warning, .attention, .information, .error').remove();
        			
        			if (json['redirect']) {
        				location = json['redirect'];
        			}
        			
        			if (json['success']) {
        				 
        				html = html + '<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>';
        			 
        				$('#notification').html(html);
        				
        				$('.success').fadeIn('slow');
        				
        				$('#cart-total').html(json['total']);
        				
        				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
        			}	
        		}
        	});
		}
	}

}